package com.tico.translatereditor.service.impl;

import com.tico.common.service.impl.AbstractService;
import com.tico.common.utils.BaseQuery;
import com.tico.common.utils.QueryResult;
import com.tico.translatereditor.domain.TaskLinsten;
import com.tico.translatereditor.mapper.TaskLinstenMapper;
import com.tico.translatereditor.service.TaskLinstenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 */
@Service
public class TaskLinstenServiceImpl extends AbstractService<TaskLinsten> implements TaskLinstenService {


   @Autowired
   TaskLinstenMapper taskLinstenMapper;

   @Override
   public TaskLinsten findById(Serializable id) {
     return taskLinstenMapper.findById(id);
   }

    @Override
    public int insertBatch(List<TaskLinsten> taskLinstens) {
      return taskLinstenMapper.insertBatch(taskLinstens);
    }

    @Override
    public int insert(TaskLinsten taskLinsten) {
      return taskLinstenMapper.insert(taskLinsten);
    }
    @Override
    public List<TaskLinsten > findByNamedParamList(Map<String,Object> param){
        return taskLinstenMapper.findByNamedParamList(param);
    }

    @Override
    public int delete(Serializable id) {
      return taskLinstenMapper.delete(id);
    }

    @Override
    public int remove(Serializable id) {
      return taskLinstenMapper.remove(id);
    }

    @Override
    public QueryResult<TaskLinsten> findPageInfo(BaseQuery baseQuery) {
        QueryResult<TaskLinsten> result = new QueryResult<TaskLinsten>();
        result.setQuery(baseQuery);
        Map
        <String, Object> params = result.getQuery().build();
        Integer amount = this.taskLinstenMapper.countPageInfo(params);
        result.setTotalRecord(amount);
        if (amount == 0) {
        return result;
        }
        List<TaskLinsten> list = taskLinstenMapper.findPageInfo(params);
        if (!CollectionUtils.isEmpty(list)) {
        result.setResultList(list);

        }
        return result;
    }
}
